
import axios from 'axios'


const Util = {
  imgPath : 'http://127.0.0.1:8011/img/',
  apiPath : 'http://127.0.0.1:8010/'
}




Util.ajax = axios.create({
  baseURL : Util.apiPath
});

Util.ajax.interceptors.response.use( res => {
  return res.data;
});

Util.getTodayTime = function () {
  const date = new Date();
  date.setHours(0);
  date.setMinutes(0);
  date.setSeconds(0);
  date.setMilliseconds(0);
  return date.getTime();
}

Util.preDay = function (timestamp = (new Date()).getTime()) {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  let month = date.getMonth() + 1;
  if (month < 10)
    month = '0'+month;
  else
    month = ''+month;
  let day = date.getDay() + 1;
  day = day<10 ? '0'+day : ''+day;
  return year+month+day;
}

export default Util;
